﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using static Volo.Abp.Ui.LayoutHooks.LayoutHooks;

namespace YAPACS.RisServer.Services.ExtendCells;

/// <summary>
/// 表格的行级flex
/// </summary>
public class RowFlex
{
    /// <summary>
    /// flex的items
    /// </summary>
    [JsonProperty(PropertyName = "Items")]
    public JArray Items { get; set; }

    /// <summary>
    /// amis内置样式
    /// </summary>
    [JsonProperty(PropertyName = "Style")]
    public JObject Style { get; set; }

    /// <summary>
    /// amis组件类型
    /// </summary>
    public String Type { get; set; } = "flex";

    /// <summary>
    /// flex主轴方向
    /// </summary>
    public String Direction { get; set; } = "row";

    /// <summary>
    /// 构造
    /// </summary>
    public RowFlex()
    {
        Style = new JObject
        {
            { "position", "relative" },
            { "inset", "auto" },
            { "flexWrap", "nowrap" },
            { "justifyContent", "flex-start" }
        };
        Items = [];
    }


    /// <summary>
    /// 生成schema
    /// </summary>
    /// <returns></returns>
    public JObject GetSchema()
    {
        JObject schema = new()
        {
            { "type", Type },
            { "direction", Direction },
            { "style", Style },
            { "items", Items },
            { "className","extend-row"}
        };
        return schema;
    }
}
